export function searchColumns() {
  return [
    {
      prop: 'channel',
      placeholder: '请输入渠道',
    },
    {
      prop: 'dateRange',
      type: 'daterange',
    },
  ]
}

export function tableColumns() {
  const getPayUser = row => {
    if (row.$index === 0 && isFinite(row?.pay_user_count / row?.active_user_count)) {
      return `${(row?.pay_user_count / row?.active_user_count) * 100}%`
    } else if (isFinite(row?.pay_user_count / row?.active_user_count)) {
      return `${(row?.pay_user_count / row?.active_user_count) * 100}%`
    } else {
      return 0
    }
  }
  return [
    {
      width: 140,
      label: '日期',
      prop: 'date',
      formatter: row => this.$formatTime(row?.date),
    },
    {
      label: '渠道',
      prop: 'channel',
    },
    {
      label: '付费人数',
      prop: 'pay_user_count',
    },
    {
      label: '活跃人数',
      prop: 'active_user_count',
    },
    {
      label: '付费率',
      prop: 'payUser',
      formatter: row => getPayUser(row),
    },
    {
      label: '付费金额',
      prop: 'amount_sum',
      formatter: row => row?.amount_sum / 10000,
    },
  ]
}
